//
//  HZRewardDetailDownView.m
//  Stock_Stategy
//
//  Created by zeroing on 17/6/5.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "HZRewardDetailDownView.h"

#define kUpDownMargin 5
#define kLeftRightMargin 15

@interface HZRewardDetailDownView()
@property (nonatomic, strong)UILabel *pTitleLabel;
@property (nonatomic, strong)UILabel *pNumLabel;
@property (nonatomic, strong)NSArray *pContentArray;
@end

@implementation HZRewardDetailDownView

#pragma mark -
#pragma mark 生命周期
- (instancetype)init{
    self = [super init];
    if (self) {
        [self commonInit];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
#pragma mark -
#pragma mark private
- (void)commonInit{
    _pTitleLabel = [UILabel new];
    _pNumLabel = [UILabel new];
    
    _pTitleLabel.text = @"策略 |";
    _pNumLabel.text = @"策略编号：";
    _pTitleLabel.textAlignment = _pNumLabel.textAlignment = NSTextAlignmentLeft;
    _pTitleLabel.font = _pNumLabel.font = [UIFont systemFontOfSize:15];
    
    [self addSubview:_pTitleLabel];
    [self addSubview:_pNumLabel];
    [self p_initConstraints];
    
    NSArray *pTempArray = @[@"策略执行金",@"止盈",@"止损",@"策略到时"];
    [self p_setDefaultViewWith:pTempArray];
}
- (void)p_initConstraints
{
    [_pTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self);
        make.left.mas_equalTo(self).offset(kLeftRightMargin);
        make.right.mas_equalTo(self);
        make.height.mas_equalTo(30);
    }];
    [_pNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_pTitleLabel.mas_bottom);
        make.left.mas_equalTo(self).offset(kLeftRightMargin);
        make.right.mas_equalTo(self);
        make.height.mas_equalTo(30);
    }];
}
- (void)p_setDefaultViewWith:(NSArray *)names
{
    UIView *pPreObject = _pNumLabel;
    NSMutableArray *pTempArray = [NSMutableArray arrayWithCapacity:4];
    for (NSString *name in names) {
        UILabel *label = [UILabel new];
        UILabel *content = [UILabel new];
        label.text = name;
        label.textAlignment = NSTextAlignmentLeft;
        content.textAlignment = NSTextAlignmentRight;
        label.font = [UIFont systemFontOfSize:15];
        content.font = [UIFont systemFontOfSize:15];
        content.text = @"--";
        
        [self addSubview:label];
        [self addSubview:content];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(pPreObject.mas_bottom);
            make.left.mas_equalTo(self).offset(kLeftRightMargin);
            make.right.mas_equalTo(content.mas_left);
            make.height.mas_equalTo(30);
        }];
        [content mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(label);
            make.right.mas_equalTo(self).offset(-kLeftRightMargin);
            make.width.mas_equalTo(label);
            make.height.mas_equalTo(label);
        }];
        
        pPreObject = label;
        [pTempArray addObject:content];
    }
    _pContentArray = pTempArray;
    
    [pPreObject mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self);
    }];
}
- (void)updateNewData:(HZRewardListModel *)data{

}
@end
